
#用于构建邮件内容
from email.mime.text import MIMEText,MIMENonMultipart

#用于构建邮件头
from email.header import Header
import smtplib

#邮件正文内容
text = '''
        啦啦啦，啦啦啦，我是卖报的小行家，大风大雨的满街跑
        
        一边跑一边叫，今天的新闻刚刚好，七个铜板就买两份报
'''
msg = MIMEText(text,'plain','utf-8')

to_addrs = ['664170687@qq.com','fanshaohua@imcc.biz']

#邮件头信息
msg['From'] = Header('664170687@qq.com')

#msg['To'] = Header('fanshaohua@imcc.biz')


#批量发送
msg['To'] = Header(','.join(to_addrs))

msg['Subject'] = Header('Send by python')


#开启发件服务器，_SSL是加密传输
server = smtplib.SMTP_SSL('smtp.qq.com')

server.connect('smtp.qq.com',465)

#登录发信邮箱
server.login('664170687@qq.com','prihofahrxjcbbfg')


#发送邮件
server.sendmail('664170687@qq.com',to_addrs,msg.as_string()) #plain 是定义为纯文本

#关闭服务器
server.quit()